<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Summary;

function RSA2signs($signatureContent, $private_key_data)
{
    $private_key_str = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($private_key_data, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----\n";
    $private_key = openssl_pkey_get_private($private_key_str);
    openssl_sign($signatureContent, $signature, $private_key, OPENSSL_ALGO_SHA256);
    $sign = base64_encode($signature);
    return $sign;
}
function RSA2data($plaintext, $public_key)
{
    $partner_public_key_str = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($public_key, 64, "\n", true) . "\n-----END PUBLIC KEY-----\n";
    $publicKey = openssl_pkey_get_public($partner_public_key_str);
    $keyDetails = openssl_pkey_get_details($publicKey);
    $keyLength = $keyDetails["bits"] / 8;
    $encryptedText = "";
    $chunks = str_split($plaintext, $keyLength - 11);
    foreach ($chunks as $chunk) {
        $encryptedChunk = "";
        if(openssl_public_encrypt($chunk, $encryptedChunk, $publicKey)) {
            $encryptedText .= $encryptedChunk;
        } else {
            exit("加密失败");
        }
    }
    $encryptedText = base64_encode($encryptedText);
    return $encryptedText;
}
function PostJsons($Posturl, $jsonData)
{
    $url = $Posturl;
    $options = ["http" => ["header" => "Content-type: application/json\r\n", "method" => "POST", "content" => $jsonData]];
    $context = stream_context_create($options);
    $response = file_get_contents($url, false, $context);
    if($response === false) {
        echo "Failed to send POST request.";
    } else {
        return $response;
    }
}
function rsaDecrypt($encryptedData, $private_key_data)
{
    $private_key_str = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($private_key_data, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----\n";
    $res = openssl_pkey_get_private($private_key_str);
    $encrypted = "";
    $part_len = 256;
    $parts = str_split($encryptedData, $part_len);
    foreach ($parts as $part) {
        $encrypted_temp = "";
        $result = openssl_private_decrypt($part, $encrypted_temp, $res);
        if(!$result) {
            exit("Decryption failed: " . openssl_error_string());
        }
        $encrypted .= $encrypted_temp;
    }
    return $encrypted;
}

?>